import { Injectable } from '@angular/core';
import { HttpClient, HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { Config } from './config.interface';
import { Observable, throwError } from 'rxjs';
import { catchError, retry,tap } from 'rxjs/operators';

@Injectable()
export class DownLoaderService {
    constructor(private http: HttpClient) { }
    configUrl = 'assets/config.json';

    getTextFile(filename: string) {
        // The Observable returned by get() is of type Observable<string>
        // because a text response was specified.
        // There's no need to pass a <string> type parameter to get().
        return this.http.get(filename, { responseType: 'text' })
            .pipe(
                tap( // Log the result or error
                    data => console.log(filename, data),
                    error => console.log(filename, error)
                )
            );
    }
}
